package com.leetcode.algo;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Algo26 {

    /**
     * 非常拉跨，想想别的办法
     * @param nums
     * @return
     */
    public int removeDuplicates(int[] nums) {
        Set<Integer> redupliSet = new HashSet<>();
        for (int num : nums) {
            redupliSet.add(num);
        }
        List<Integer> integerList = redupliSet.stream().sorted().collect(Collectors.toList());

        for (int i = 0; i < nums.length; i++) {
            if (i < integerList.size()) {
                nums[i] = integerList.get(i);
            }else {
                nums[i] = 0;
            }
        }
        return redupliSet.toArray().length;
    }

    public static void main(String[] args) {
        Algo26 algo26 = new Algo26();
        System.out.println(algo26.removeDuplicates(new int[]{-3,-1,0,0,0,3,3}));
    }
}
